import requests

login_url = 'https://cn.baozimhcn.com/user/signin'
cover_url = 'https://cn.baozimhcn.com/user/my_bookshelf'
session = requests.Session()

# 模拟浏览器请求头
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
    "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
    "Accept-Encoding": "gzip, deflate, br",
    "Connection": "keep-alive",
    "Upgrade-Insecure-Requests": "1",  # 告诉服务器允许HTTP到HTTPS的升级
}

# 获取登录页Cookie
response = session.get(login_url, headers=headers)
print("登录页Cookie:", response.cookies)

# 提交登录信息（请确认表单字段是否正确）
login_data = {
    'username': '2283765021@qq.com',
    'password': '2003032151lol'
}
response = session.post(login_url, data=login_data, headers=headers)
print(response.text)
if session.cookies:
    cover_response = session.get(cover_url, headers=headers)
    print(cover_response.text)

